package at.fhooe.serializer;

import at.fhooe.agaeScriptDsl.AgaeScriptDslPackage;
import at.fhooe.agaeScriptDsl.BusinessLogic;
import at.fhooe.agaeScriptDsl.Button;
import at.fhooe.agaeScriptDsl.Domainmodel;
import at.fhooe.agaeScriptDsl.HandlerItem;
import at.fhooe.agaeScriptDsl.Import;
import at.fhooe.agaeScriptDsl.Label;
import at.fhooe.agaeScriptDsl.PackageDeclaration;
import at.fhooe.agaeScriptDsl.Screen;
import at.fhooe.agaeScriptDsl.TextField;
import at.fhooe.services.AgaeScriptDslGrammarAccess;
import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;

@SuppressWarnings("all")
public class AgaeScriptDslSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private AgaeScriptDslGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == AgaeScriptDslPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case AgaeScriptDslPackage.BUSINESS_LOGIC:
				if(context == grammarAccess.getAbstractElementRule() ||
				   context == grammarAccess.getBusinessLogicRule()) {
					sequence_BusinessLogic(context, (BusinessLogic) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.BUTTON:
				if(context == grammarAccess.getButtonRule() ||
				   context == grammarAccess.getGuiItemRule()) {
					sequence_Button(context, (Button) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.DOMAINMODEL:
				if(context == grammarAccess.getDomainmodelRule()) {
					sequence_Domainmodel(context, (Domainmodel) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.HANDLER_ITEM:
				if(context == grammarAccess.getHandlerItemRule()) {
					sequence_HandlerItem(context, (HandlerItem) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.IMPORT:
				if(context == grammarAccess.getAbstractElementRule() ||
				   context == grammarAccess.getImportRule()) {
					sequence_Import(context, (Import) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.LABEL:
				if(context == grammarAccess.getGuiItemRule() ||
				   context == grammarAccess.getLabelRule()) {
					sequence_Label(context, (Label) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.PACKAGE_DECLARATION:
				if(context == grammarAccess.getAbstractElementRule() ||
				   context == grammarAccess.getPackageDeclarationRule()) {
					sequence_PackageDeclaration(context, (PackageDeclaration) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.SCREEN:
				if(context == grammarAccess.getAbstractElementRule() ||
				   context == grammarAccess.getScreenRule()) {
					sequence_Screen(context, (Screen) semanticObject); 
					return; 
				}
				else break;
			case AgaeScriptDslPackage.TEXT_FIELD:
				if(context == grammarAccess.getGuiItemRule() ||
				   context == grammarAccess.getTextFieldRule()) {
					sequence_TextField(context, (TextField) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (name=ID layoutName=STRING handlerItems+=HandlerItem*)
	 */
	protected void sequence_BusinessLogic(EObject context, BusinessLogic semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID buttonText=STRING btnHandlerName=STRING)
	 */
	protected void sequence_Button(EObject context, Button semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.GUI_ITEM__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.GUI_ITEM__NAME));
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.BUTTON__BUTTON_TEXT) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.BUTTON__BUTTON_TEXT));
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.BUTTON__BTN_HANDLER_NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.BUTTON__BTN_HANDLER_NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getButtonAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getButtonAccess().getButtonTextSTRINGTerminalRuleCall_3_0(), semanticObject.getButtonText());
		feeder.accept(grammarAccess.getButtonAccess().getBtnHandlerNameSTRINGTerminalRuleCall_5_0(), semanticObject.getBtnHandlerName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     elements+=AbstractElement*
	 */
	protected void sequence_Domainmodel(EObject context, Domainmodel semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID componentToName=STRING componentFromName=STRING)
	 */
	protected void sequence_HandlerItem(EObject context, HandlerItem semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.HANDLER_ITEM__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.HANDLER_ITEM__NAME));
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.HANDLER_ITEM__COMPONENT_TO_NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.HANDLER_ITEM__COMPONENT_TO_NAME));
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.HANDLER_ITEM__COMPONENT_FROM_NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.HANDLER_ITEM__COMPONENT_FROM_NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getHandlerItemAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getHandlerItemAccess().getComponentToNameSTRINGTerminalRuleCall_3_0(), semanticObject.getComponentToName());
		feeder.accept(grammarAccess.getHandlerItemAccess().getComponentFromNameSTRINGTerminalRuleCall_5_0(), semanticObject.getComponentFromName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     importedNamespace=QualifiedNameWithWildcard
	 */
	protected void sequence_Import(EObject context, Import semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.IMPORT__IMPORTED_NAMESPACE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.IMPORT__IMPORTED_NAMESPACE));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getImportAccess().getImportedNamespaceQualifiedNameWithWildcardParserRuleCall_1_0(), semanticObject.getImportedNamespace());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID labelText=STRING)
	 */
	protected void sequence_Label(EObject context, Label semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.GUI_ITEM__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.GUI_ITEM__NAME));
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.LABEL__LABEL_TEXT) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.LABEL__LABEL_TEXT));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getLabelAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getLabelAccess().getLabelTextSTRINGTerminalRuleCall_3_0(), semanticObject.getLabelText());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=QualifiedName elements+=AbstractElement*)
	 */
	protected void sequence_PackageDeclaration(EObject context, PackageDeclaration semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID guiItems+=GuiItem*)
	 */
	protected void sequence_Screen(EObject context, Screen semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID textFieldText=STRING)
	 */
	protected void sequence_TextField(EObject context, TextField semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.GUI_ITEM__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.GUI_ITEM__NAME));
			if(transientValues.isValueTransient(semanticObject, AgaeScriptDslPackage.Literals.TEXT_FIELD__TEXT_FIELD_TEXT) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AgaeScriptDslPackage.Literals.TEXT_FIELD__TEXT_FIELD_TEXT));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getTextFieldAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.accept(grammarAccess.getTextFieldAccess().getTextFieldTextSTRINGTerminalRuleCall_3_0(), semanticObject.getTextFieldText());
		feeder.finish();
	}
}
